Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/added retrieval info functions #28

Merged
merged 11 commits into from
Jun 5, 2024
Merged

feat/added retrieval info functions #28

merged 11 commits into from
Jun 5, 2024

Conversation

gidonkatten
Copy link
Member

Includes:

  • pool info
  • rate limit info
  • loan type info
  • oracle info
  • user loan ids
  • user loan info

@gidonkatten gidonkatten requested a review from palace22 June 4, 2024 12:11
package.json Outdated
@@ -27,6 +27,10 @@
"format": "prettier --write .",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"dnum": "^2.12.0",
"viem": "^2.10.5"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viem version should be "^2.13.2"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -84,3 +116,409 @@ export async function getSendTokenAdapterFees(
// get return adapter fee
return await hubBridgeRouter.read.getSendFee([returnMessage]);
}

export async function loanTypeInfo(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call this getLoanTypeInfo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 7 to 26
export type AbiLoanPool = {
collateralUsed: bigint;
borrowUsed: bigint;
collateralCap: bigint;
borrowCap: bigint;
collateralFactor: number;
borrowFactor: number;
liquidationBonus: number;
liquidationFee: number;
isAdded: boolean;
isDeprecated: boolean;
reward: {
lastUpdateTimestamp: bigint;
minimumAmount: bigint;
collateralSpeed: bigint;
borrowSpeed: bigint;
collateralRewardIndex: bigint;
borrowRewardIndex: bigint;
};
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could updata it with ReadContractReturnType<typeof LoanManagerAbi, "getLoanPool">;, same with others ts(2589)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/chains/evm/hub/modules/folks-hub-loan.ts Outdated Show resolved Hide resolved
],
allowFailure: false,
},
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining return types (e.g. ReadContractReturnType<typeof LoanManagerAbi, "getLoanPool">) for each of these returns we can avoid unknown

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};
}

export async function getUserLoanIds(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use fetch/get naming convention as https://github.com/Folks-Finance/folks-finance-xchain-js-sdk/blob/feat/account-id-info/src/chains/evm/hub/modules/folks-hub-account.ts#L82 , creating utils methods so that we can further filter events if needed e.g. CreateUserLoan with loanTypeId

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ae13a30 with added ability to filter on loan type

src/chains/evm/hub/modules/folks-hub-loan.ts Show resolved Hide resolved
src/chains/evm/hub/modules/folks-hub-loan.ts Show resolved Hide resolved
@gidonkatten gidonkatten requested a review from palace22 June 5, 2024 11:03
Co-authored-by: Stefano Faieta <[email protected]>
Copy link
Collaborator

@palace22 palace22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gidonkatten gidonkatten merged commit 65ee3b4 into main Jun 5, 2024
2 checks passed
@gidonkatten gidonkatten deleted the feat/info branch June 5, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants